﻿(function () {
    var TileFactory = function () {

    };
    TileFactory.prototype.createObject = function () {
        var min = 1;
        var max = 7;

        var randomNumberGenerator = new tetris.RandomNumberGenerator();

        var randomInteger = randomNumberGenerator.generateInteger(min, max);

        var tile;

        switch (randomInteger) {
            case 1:
                tile = new tetris.FallingLine;
                break;
            case 2:
                tile = new tetris.FallingLReversed;
                break;
            case 3:
                tile = new tetris.FallingL;
                break;
            case 4:
                tile = new tetris.FallingSquare;
                break;
            case 5:
                tile = new tetris.FallingZReversed;
                break;
            case 6:
                tile = new tetris.FallingT;
                break;
            case 7:
                tile = new tetris.FallingZ;
                break;
            default:
                throw new Error("Unknown type of piece");
        }

        return tile;
    };

    tetris.TileFactory = TileFactory;
})();